package edu.sctu.wangxiaoqiang.projectOne;

import java.util.HashMap;
import java.util.Scanner;

/**
 * Created by user06 on 2015/5/31.
 */

public class MachinePos {
    /**
     * 判断卡上余额
     * @return
     */
    public int panduan(){

        TianFuCard tianFuCard = new TianFuCard();
        int balance = tianFuCard.setMoney(10);

        System.out.println("您卡上余额为："+balance);
        while (balance<=2){
            Autosell autosell = new Autosell();
            balance = autosell.reacharge(balance);
            break;
        }
        return balance;
    }
    /**
     * 刷卡机
     * @param zhongdian 终点站
     * @param number 终点站号
     */
    public void swingCard(String zhongdian,int number){
        int balance = panduan();
        Autosell autosell = new Autosell();
        HashMap<Integer,String> rode = autosell.setRode();

        for(int i = 1;i<rode.size();i++) {
            if ( rode.get(i).equals(zhongdian)) {
                int zhanshu = Math.abs(i - number);
                if(zhanshu > 0 && zhanshu<2){
                        System.out.println("收费2元，"+"余额为："+ (balance - 2));

                }else if(zhanshu < 6){
                        System.out.println("收费4元，"+"余额为："+ (balance - 4));

                }else if(zhanshu < 8){
                        System.out.println("收费5元，"+"余额为："+ (balance - 5));

                }else {
                        System.out.println("收费6元，"+"余额为："+ (balance - 6));

                }
            }
        }

    }

}


